package com.kapcb.async.worker;

/**
 * <a>Title: WorkResult </a>
 * <a>Author: Kapcb <a>
 * <a>Description: 执行结果 <a>
 *
 * @author Kapcb
 * @version 1.0
 * @date 2024/5/9 21:38
 * @since 1.0
 */
public class WorkResult<R> {

    /**
     * 任务执行的结果
     */
    private R result;

    /**
     * 任务执行结果的状态
     */
    private ResultState resultState;

    private Exception exception;

    public WorkResult() {
    }

    public WorkResult(R result, ResultState resultState, Exception exception) {
        this.result = result;
        this.resultState = resultState;
        this.exception = exception;
    }

    public WorkResult(R result, ResultState resultState) {
        this(result, resultState, null);
    }

    public static <R> WorkResult<R> defaultResult() {
        return new WorkResult<>(null, ResultState.DEFAULT);
    }


    public R getResult() {
        return result;
    }

    public void setResult(R result) {
        this.result = result;
    }

    public ResultState getResultState() {
        return resultState;
    }

    public void setResultState(ResultState resultState) {
        this.resultState = resultState;
    }

    public Exception getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    @Override
    public String toString() {
        return "WorkResult{" +
                "result=" + result +
                ", resultState=" + resultState +
                ", exception=" + exception +
                '}';
    }
}
